package com.runjian.rundo.iot.agent.iec104.consts;

import lombok.Getter;

/**
 * 动作
 */
@Getter
public enum Action {

    // ------监视方向的过程信息------
    SCHEDULED_C_IC_NA_1(1, "定时总召唤"), SCHEDULED_READ_C_CS_NA_1(2, "定时读取时钟信息"), CANCEL_ALL_TASK(2, "取消所有任务"), START_TASK(2, "开始任务"),
    STOP_TASK(2, "终止任务"), SCHEDULED_READ_C_CS_NA_1_CANCEL(2, "定时读取时钟信息取消"), SINGLE_C_CS_NA_1(3, "单次定时时钟同步"), SEND_S_DETECT(5, "发送S侦"),;

    private short code;
    private String name;

    Action(int code, String name) {
        this.code = (short)code;
        this.name = name;
    }

    public static Action valueOfCode(short code) {
        for (Action value : Action.values()) {
            if (value.code == code) {
                return value;
            }
        }
        return null;
    }

    public String getCodeHex() {
        return String.format("%02X", code);
    }
}
